Results 1 to 4 of 4

Thread: Is there a signal in QTableWidget that “fires” when a cell has lost focus?

  1. #1
    Join Date
    Sep 2006
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Red face Is there a signal in QTableWidget that “fires” when a cell has lost focus?

    I need to detect when a cell in my QTableWidget spreadsheet has lost focus so I can check to see if its value has changed.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is there a signal in QTableWidget that “fires” when a cell has lost focus?

    Maybe this will help?
    void QTableWidget::cellChanged ( int row, int column ) [signal]
    This signal is emitted whenever the data of the item in the cell specidied by row and column has changed.
    or this:
    void QTableWidget::currentCellChanged ( int currentRow, int currentColumn, int previousRow, int previousColumn ) [signal]
    This signal is emitted whenever the current cell changes. The cell specified by previousRow and previousColumn is the cell that previously had the focus, the cell specified by currentRow and currentColumn is the new current cell.

  3. #3
    Join Date
    Sep 2006
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Is there a signal in QTableWidget that “fires” when a cell has lost focus?

    Thanks for the quick reply.

    I am already using the currentItemChanged signal and it works fine when I move from one cell to another cell in the QTableWidget. This signal isn't being sent, however, when I mouse-click outside the spreadsheet. In this case, the focus does indeed move off of the cell I was in, and the cell contasins a new value, but I'm not aware of it.

    I ended up using the mouseReleaseEvent to detect this situation. I needed to store the QTableWidgetItem of the cell I was in the last time and this allowed me to detect the new value, after the fact.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Is there a signal in QTableWidget that “fires” when a cell has lost focus?

    Quote Originally Posted by tstankey
    In this case, the focus does indeed move off of the cell I was in, and the cell contasins a new value, but I'm not aware of it.
    Then maybe cellChanged() will be better? There is also QFocusEvent, which you can catch using an event filter or by reimplementing focusOutEvent().

Similar Threads

  1. Center a widget in a cell on a QTableWidget
    By roleroz in forum Qt Programming
    Replies: 16
    Last Post: 5th March 2009, 14:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.